package com.zh.search.dataSource;

import cn.hutool.core.bean.BeanUtil;
import com.zh.search.domain.dto.SearchDto;
import com.zh.search.domain.dto.VideoSearchDto;
import com.zh.search.service.IEsService;
import com.zh.web.base.PageApiResult;
import com.zh.web.domain.media.vo.VideoVo;
import org.springframework.stereotype.Component;

@Component
public class VideoEsDataSource implements EsDataSource<VideoVo> {

    private final IEsService esService;

    public VideoEsDataSource(IEsService esService) {
        this.esService = esService;
    }

    @Override
    public PageApiResult<VideoVo> doSearch(SearchDto searchDto) {
        VideoSearchDto videoSearchDto = new VideoSearchDto();
        BeanUtil.copyProperties(searchDto, videoSearchDto);
        return esService.searchVideoFromEs(videoSearchDto);
    }

}
